<!--
//==================================
//  Weather for google earth v1.0
//  更新时间: 2007-08-24
//  embont@gmail.com
//  www.dnxh.cn
//==================================
--><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
	<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes"/>
	<xsl:param name="dnam"/>
	<xsl:param name="ServerURL"/>
	<xsl:template match="/">
		<xsl:variable name="hour" select="substring-before(/weather/loc/tm,':')"/>
		<xsl:variable name="dnFlag">
			<xsl:choose>
				<xsl:when test="contains(/weather/loc/tm,'AM')">
					<xsl:choose>
						<xsl:when test="($hour != 12) and ($hour &gt; 6)">d</xsl:when>
						<xsl:otherwise>n</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
				<xsl:when test="contains(/weather/loc/tm,'PM')">
					<xsl:choose>
						<xsl:when test="($hour = 12) or ($hour &lt; 7)">d</xsl:when>
						<xsl:otherwise>n</xsl:otherwise>
					</xsl:choose>
				</xsl:when>
			</xsl:choose>
		</xsl:variable>
		<xsl:variable name="BGColor">
			<xsl:choose>
				<xsl:when test="$dnFlag = 'd'">FFCC99</xsl:when>
				<xsl:otherwise>BBBBBB</xsl:otherwise>
			</xsl:choose>
		</xsl:variable>
		<kml xmlns="http://earth.google.com/kml/2.1">
			<Document>
				<name>
				<xsl:value-of select="/weather/loc/dnam"/>
				</name>
				<open>0</open>
				<Placemark>
					<name>
					<xsl:value-of select="/weather/loc/dnam"/>
				    </name>
					<Snippet maxLines="2"/>
					<description>
						<xsl:text disable-output-escaping="yes">&lt;![CDATA[</xsl:text><table width="510"><tr><td width="260"><b>Current conditions:</b><br/><xsl:value-of select="/weather/cc/t"/><br/>Feels Like : <xsl:choose><xsl:when test = "/weather/cc/tmp = 'N/A'">--</xsl:when><xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="/weather/cc/tmp"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="/weather/cc/tmp"/>F</xsl:otherwise></xsl:choose><br/>Wind : <xsl:value-of select="/weather/cc/wind/t"/>-<xsl:choose><xsl:when test = "/weather/cc/wind/s = 'N/A'">--</xsl:when><xsl:otherwise><xsl:value-of select="/weather/cc/wind/s"/><xsl:value-of select="/weather/head/us"/></xsl:otherwise></xsl:choose><br/>Humidity : <xsl:choose><xsl:when test = "/weather/cc/hmid = 'N/A'">--</xsl:when><xsl:otherwise><xsl:value-of select="/weather/cc/hmid"/>%</xsl:otherwise></xsl:choose><br/>Visibility : <xsl:choose><xsl:when test = "/weather/cc/vis = 'N/A'">--</xsl:when><xsl:otherwise><xsl:value-of select="/weather/cc/vis"/><xsl:value-of select="/weather/head/ud"/></xsl:otherwise></xsl:choose><br/>Sunrise : <xsl:value-of select="/weather/loc/sunr"/><br/>Sunset : <xsl:value-of select="/weather/loc/suns"/><br/>Updated Time : <xsl:value-of select="/weather/cc/lsup"/><br/><a><xsl:attribute name="href"><xsl:value-of select="$ServerURL"/>/updata.asp?code=<xsl:value-of select="weather/loc/@id"/></xsl:attribute><font color="#EC6810">Immediately update</font></a></td><td width="250"><img border="0"><xsl:attribute name="src"><xsl:value-of select="$ServerURL"/>/img/icon/<xsl:choose><xsl:when test = "/weather/cc/icon = '-'">44d</xsl:when><xsl:otherwise><xsl:value-of select="/weather/cc/icon"/><xsl:value-of select="$dnFlag"/></xsl:otherwise></xsl:choose>.png</xsl:attribute></img></td></tr></table><b>Detailed Forecast:</b><br/><table><tr><td><xsl:choose><xsl:when test="(($hour &gt; 1) and ($hour &lt; 12)) and (contains(/weather/loc/tm,'PM'))">Tonight<br/><img border="0"><xsl:attribute name="src"><xsl:value-of select="$ServerURL"/>/img/icon/<xsl:value-of select="weather/dayf/day[@d = 0]/part[@p = 'n']/icon"/>s.png</xsl:attribute></img><br/><xsl:value-of select="weather/dayf/day[@d = 0]/part[@p = 'n']/t"/><br/>High : <xsl:choose>  <xsl:when test = "weather/dayf/day[@d = 0]/hi = 'N/A'">--</xsl:when><xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="weather/dayf/day[@d = 0]/hi"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="weather/dayf/day[@d = 0]/hi"/><xsl:value-of select="/weather/head/ut"/></xsl:otherwise></xsl:choose><br/>Low : <xsl:choose><xsl:when test = "weather/dayf/day[@d = 0]/low = 'N/A'">--</xsl:when>  <xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="weather/dayf/day[@d = 0]/low"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="weather/dayf/day[@d = 0]/low"/><xsl:value-of select="/weather/head/ut"/></xsl:otherwise></xsl:choose><br/></xsl:when><xsl:otherwise>Today<br/><img border="0"><xsl:attribute name="src"><xsl:value-of select="$ServerURL"/>/img/icon/<xsl:value-of select="weather/dayf/day[@d = 0]/part[@p = 'd']/icon"/>s.png</xsl:attribute></img><br/><xsl:value-of select="weather/dayf/day[@d = 0]/part[@p = 'd']/t"/><br/>High : <xsl:choose><xsl:when test = "weather/dayf/day[@d = 0]/hi = 'N/A'">--</xsl:when><xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="weather/dayf/day[@d = 0]/hi"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="weather/dayf/day[@d = 0]/hi"/><xsl:value-of select="/weather/head/ut"/></xsl:otherwise></xsl:choose><br/>Low : <xsl:choose><xsl:when test = "weather/dayf/day[@d = 0]/low = 'N/A'">--</xsl:when>  <xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="weather/dayf/day[@d = 0]/low"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="weather/dayf/day[@d = 0]/low"/><xsl:value-of select="/weather/head/ut"/></xsl:otherwise></xsl:choose><br/></xsl:otherwise></xsl:choose>    </td><xsl:for-each select="/weather/dayf/day[@d != 0]"><td><xsl:value-of select="./@t"/><br/><img border="0"><xsl:attribute name="src"><xsl:value-of select="$ServerURL"/>/img/icon/<xsl:value-of select="./part[@p = 'd']/icon"/>s.png</xsl:attribute></img><br/><xsl:value-of select="./part[@p = 'd']/t"/><br/>High : <xsl:choose><xsl:when test = "hi = 'N/A'">-- </xsl:when><xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="hi"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="hi"/><xsl:value-of select="/weather/head/ut"/></xsl:otherwise></xsl:choose><br/>Low : <xsl:choose><xsl:when test = "low = 'N/A'">--</xsl:when><xsl:when test = "/weather/head/ut = 'C'"><xsl:value-of select="low"/>℃</xsl:when><xsl:otherwise><xsl:value-of select="low"/><xsl:value-of select="/weather/head/ut"/></xsl:otherwise></xsl:choose><br/></td></xsl:for-each></tr></table><xsl:text disable-output-escaping="yes">]]&gt;</xsl:text>
					</description>
					<styleUrl><xsl:value-of select="$ServerURL"/>/style/styleEN.asp#styleMapExample<xsl:choose><xsl:when test = "/weather/cc/icon = '-'">44</xsl:when><xsl:otherwise><xsl:value-of select="/weather/cc/icon"/></xsl:otherwise></xsl:choose><xsl:value-of select="$BGColor"/></styleUrl>
					<Point>
						<coordinates>
							<xsl:value-of select="/weather/loc/lon"/>,<xsl:value-of select="/weather/loc/lat"/>,0</coordinates>
					</Point>
				</Placemark>
			</Document>
		</kml>
	</xsl:template>
</xsl:stylesheet>